import {getProductList} from "@/api/jd";
export default {
    namespaced:true,
    state:{
        productList:[]
    },
    mutations:{
        SET_PRODUCT_LIST(state,productList){
            state.productList = productList;
        }
    },
    actions:{
        async getProductListAsync({state,commit,dispatch}){
            try{
                if(state.productList.length>0) return;
                const response = await getProductList();
                commit("SET_PRODUCT_LIST",(response.data.priceModuleList.find(v=>v.type===1)?.productList || []));
            }catch (err){
                setTimeout(()=>{
                    dispatch("getProductListAsync");
                },1000)
            }

        }
    }
}